﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Red.GameData.Raw
{
    public partial class DataValue
    {
        /// <summary>
        /// The value ID - each value is tracked able through the system using it's ID
        /// This element of additional tracing is crucial for implementing features like array element suppressing or overriding
        /// </summary>
        public Guid ID { get; private set; }

        /// <summary>
        /// Parent data property this value is defined for
        /// </summary>
        public DataProperty Parent { get; private set; }

        /// <summary>
        /// Get/Set value of this data value entry
        /// NOTE: setting a new value will mark file as modified
        /// </summary>
        public String Value
        {
            get
            {
                return _value;
            }
            set
            {
                if (_value != value)
                {
                    _value = value;
                    Parent.MarkModified();
                }
            }
        }

        /// <summary>
        /// Initialize
        /// </summary>
        /// <param name="_parent"></param>
        internal DataValue(DataProperty parent, Guid id, string value)
        {
            Debug.Assert(parent != null);
            Debug.Assert(id != Guid.Empty);

            ID = id;
            Parent = parent;
            _value = value;
        }

        /// <summary>
        /// Value of this value entry
        /// NOTE: the data side of the system is type-agnostic and ALL are stored as text for simplicity
        /// Only after you get the Reflection data you can start to interpret this string as some specific type
        /// </summary>
        private string _value;

    }
}
